package task.dao;

import java.util.ArrayList;
import java.util.Iterator;


import org.dom4j.Document;
import org.dom4j.Element;


public class TaskDaoImpl implements TaskDao {

	private String[] tasks;

	public TaskDaoImpl(Document doc) {
		ArrayList<String> list = new ArrayList<String>();
		Element root = doc.getRootElement();
		Element _tasks = root.element("tasks");
		for ( Iterator<?> i = _tasks.elementIterator( "task" ); i.hasNext(); ) {
            Element task = (Element) i.next();
            String taskClass = task.getText();
			list.add(taskClass);
		}
		tasks = list.toArray(new String[0]);
	}
	@Override
	public void delete(String taskClass) {
		throw new UnsupportedOperationException();
	}

	@Override
	public String[] getTasks() {
		return tasks;
	}

	@Override
	public void save(String taskClass) {
		throw new UnsupportedOperationException();
	}

}
